package cn.boysoft.module.security.model.vo;

import java.util.List;

import org.apache.commons.lang.StringUtils;

import cn.boysoft.core.model.JEEQuery;
import cn.boysoft.core.model.PageParam;
import cn.boysoft.core.model.QueryCondition;

public class UserPageParam extends PageParam implements JEEQuery{

	private String userName;
	private String realName;
	public String getUserName() {
		return userName;
	}
	public void setUserName(String userName) {
		this.userName = userName;
	}
	public String getRealName() {
		return realName;
	}
	public void setRealName(String realName) {
		this.realName = realName;
	}
	@Override
	public QueryCondition buildQueryCondition() {
		QueryCondition queryCondition = new QueryCondition();
		StringBuilder hql = queryCondition.getHql();
		List<Object> values = queryCondition.getValues();
		hql.append(" from  UserEntity e where 1=1 ");
		if(StringUtils.isNotEmpty(this.userName)){
			hql.append(" and e.userName like ?");
			values.add('%'+this.userName+'%');
		}
		if(StringUtils.isNotEmpty(this.realName)){
			hql.append(" and e.realName like ?");
			values.add('%'+this.realName+'%');
		}
		return queryCondition;
	}
	
}
